<%@ page language="java" contentType="text/html; charset=UTF-8"
	pageEncoding="UTF-8"%>
<!DOCTYPE html>
<html>
<head>
<meta charset="UTF-8">
<title>个人资料</title>
<link rel="stylesheet" href="${ctx}/resources/layui/css/layui.css">
</head>
<body style="padding: 10px;">
	<form class="layui-form" method="post" lay-filter="dataFrm"
		id="dataFrm">
		<div class="layui-form-item">
			<!-- id，隐藏域-->
			<input type="text" id="userid" name="userid" hidden="">
			<div class="layui-block">
				<label class="layui-form-label">登录名:</label>
				<div class="layui-input-block">
					<input type="text" id="loginname" name="loginname"
						readonly="readonly" autocomplete="off"
						class="layui-input">
				</div>
			</div>
			<div class="layui-block">
				<label class="layui-form-label">姓名:</label>
				<div class="layui-input-block">
					<input type="text" id="realname" name="realname" placeholder="请输入姓名"
						lay-verify="required" autocomplete="off" class="layui-input">
				</div>
			</div>
			<div class="layui-block">
				<label class="layui-form-label">身份证号:</label>
				<div class="layui-input-block">
					<input type="text" id="identity" name="identity" placeholder="请输入身份证号"
						lay-verify="required" autocomplete="off" class="layui-input">
				</div>
			</div>
			<div class="layui-block">
				<label class="layui-form-label">地址:</label>
				<div class="layui-input-block">
					<input type="text" id="address" name="address" placeholder="请输入地址"
						autocomplete="off" class="layui-input">
				</div>
			</div>
			<div class="layui-block">
				<label class="layui-form-label">电话:</label>
				<div class="layui-input-block">
					<input type="text" id="phone" name="phone" placeholder="请输入地址"
						autocomplete="off" class="layui-input">
				</div>
			</div>
			<div class="layui-block">
				<label class="layui-form-label">职位:</label>
				<div class="layui-input-inline">
					<input type="text" id="position" name="position" placeholder="请输入职位"
						readonly="readonly" autocomplete="off" class="layui-input">
				</div>
			</div>
			<div class="layui-block">
				<label class="layui-form-label">性别:</label>
				<div class="layui-input-block">
					<input type="radio" id="sex1" name="sex" value="1" title="男">
					<input type="radio" id="sex0" name="sex" value="0" title="女">
				</div>
			</div>
		</div>
		<div class="layui-form-item" style="margin: 10px; text-align: right;">
			<div class="layui-input-block">
				<button type="button"
					class="layui-btn layui-icon layui-icon-release" lay-submit=""
					lay-filter="doSubmit">保存修改</button>
				<button type="button" class="layui-btn layui-btn-warm layui-icon layui-icon-refresh"
					id="doReset">重置</button>
			</div>
		</div>
	</form>
	<script src="${ctx}/resources/layui/layui.js"></script>
	<script>
		layui.use(['element','layer', 'form' ],function() {
			var $ = layui.$;
			var layer = layui.layer;
			var form = layui.form;
			$(document).ready(function(){
				initForm();
			});
			function initForm(){
				form.val("dataFrm",{
					"userid":"${user.userid}",
					"loginname":"${user.loginname}",
					"realname":"${user.realname}",
					"identity":"${user.identity}",
					"address":"${user.address}",
					"phone":"${user.phone}",
					"position":"${user.position}",
					"sex":"${user.sex}"
				});
			}
			form.on("submit(doSubmit)",function(data){
				console.log(data.field);
				layer.confirm("确定要保存已修改个人资料？",function(index){
					$.post("${ctx}/user/updateUser.action",data.field,function(result){
						if(result.success){
							layer.msg("修改成功，请重新登录以更新信息");
						}else {
							layer.msg(result.message);
						}
					});
				});
			});
			$("#doReset").click(function(){
				initForm();
			});
		});
	</script>
</body>
</html>